﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model;
using BLL;
using System.Text;

namespace OA.Controllers
{
    public class SelectMemberController : Controller
    {
        //
        // GET: /SelectMember/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult SelectMember()
        {


            return View();
        }
        public ActionResult Select(FormCollection fc)
        {
            string select1, select2, select3,tiaojian1,tiaojian2,tiaojian3;
            memberInfoManager mb = new memberInfoManager();
            MemberList ml = new MemberList();
            string memberId = fc["memberId"].ToString();
            string memberName = fc["memberName"].ToString();
            string mobile = fc["mobile"].ToString();
            select1 = fc["select1"].ToString();
            select2 = fc["select2"].ToString();
            select3 = fc["select3"].ToString();
            tiaojian1 = fc["tiaojian1"].ToString();
            tiaojian2 = fc["tiaojian2"].ToString();
            tiaojian3 = fc["tiaojian3"].ToString();
            List<MemberList> member = mb.GetMemberByConditions(memberId, memberName,mobile, select1, select2, select3, tiaojian1, tiaojian2, tiaojian3).ToList();
            StringBuilder sb = new StringBuilder();
            sb.Append("<tr class=\"DGHeaderStyle\">"); 
            sb.Append("<th> 会员编号</th>");
            sb.Append("<th>会员姓名</th>");
            sb.Append("<th>会员性别</th>");
            sb.Append("<th>手机号码 </th>");
            sb.Append("<th>联系电话</th>");
            sb.Append("<th>Email</th>");
            sb.Append("<th>证件号码</th>");
            sb.Append("<th>生日</th>");
            sb.Append("<th>卡类型</th>");
            sb.Append("<th>卡内余额</th>");
            sb.Append("<th>积分</th>");
            sb.Append(" <th>卡状态</th>");
            sb.Append("<th>登记日期</th>");
            sb.Append("<th>截止日期</th>");
            sb.Append("<th>消费总额</th>");
            sb.Append("<th>备注</th>");
            sb.Append("<th>婚姻</th>");
            sb.Append("<th>邮编</th>");
            sb.Append("<th>住址</th>");
            sb.Append("<th>区域</th>");
            sb.Append("<th>会员类型</th>");
            sb.Append("<th>推介人</th>");
            sb.Append("</tr>");
            for (int i = 0; i <= member.Count(); i++)
            {
                try
                {
                    sb.Append("<tr onmouseover=\"this.style.backgroundColor='#BCD2EE';cursor='default'\" onmouseout=\"this.style.backgroundColor='white'\">");
                    sb.Append("<td>" + member[i].memberID + "</td>");
                    sb.Append("<td>" + member[i].memberName + "</td>");
                    sb.Append("<td>" + member[i].sex + "</td>");
                    sb.Append("<td>" + member[i].mobile + "</td>");
                    sb.Append("<td>" + member[i].Tel + "</td>");
                    sb.Append("<td>" + member[i].Email + "</td>");
                    sb.Append("<td>" + member[i].IDNumber + "</td>");
                    sb.Append("<td>" + Convert.ToDateTime(member[i].birthDay).ToString("yyyy-MM-dd") + "</td>");
                    sb.Append("<td>" + member[i].cardType + "</td>");
                    sb.Append("<td>" + Convert.ToDecimal(member[i].Balance).ToString("#0.00") + "</td>");
                    sb.Append("<td>" + member[i].point + "</td>");
                    sb.Append("<td>" + member[i].status + "</td>");
                    sb.Append("<td>" + Convert.ToDateTime(member[i].createDate).ToString("yyyy-MM-dd") + "</td>");
                    sb.Append("<td>" + Convert.ToDateTime(member[i].expiresDate).ToString("yyyy-MM-dd") + "</td>");
                    sb.Append("<td>" + Convert.ToDecimal(member[i].consume).ToString("#0.00") + "</td>");
                    sb.Append("<td>" + member[i].memo + "</td>");
                    sb.Append("<td>" + member[i].Marriage + "</td>");
                    sb.Append("<td>" + member[i].Zip + "</td>");
                    sb.Append("<td>" + member[i].Address + "</td>");
                    sb.Append("<td>" + member[i].areaID + "</td>");
                    sb.Append("<td>" + member[i].MemberType + "</td>");
                    sb.Append("<td>" + member[i].tuiguangren + "</td>");
                    sb.Append("</tr>");
                }
                catch (Exception)
                {

                    break;
                }

            }
            return Content(sb.ToString());
           

        }
    }
}
